﻿<!--#include file="../inc/common.asp" -->
<!--#include file="skin_templet.asp" -->
<%
    if not userRightObj.canManage then
        message("您没有设置权限")
    end if
    call OpenDB
    
    dim template_id, parent_id
    dim template_name, template_code, template_code2, template_desc, is_published
    
    template_id = trim(request("template_id"))
    parent_id = trim(request("parent_id"))

    sql = "select template_name, template_code, template_code2, template_desc, is_published, parent_id from blog_template where template_id="
    
    if template_id<>"" then
        template_id = clng(template_id)
        sql = sql & template_id
        rs.open sql, conn, 1, 1
        if not rs.eof then
            template_name = rs("template_name")
            template_code = rs("template_code")
            template_code2 = rs("template_code2")
            template_desc = rs("template_desc")
            is_published = rs("is_published")
            parent_id = rs("parent_id")
        end if
        rs.close()
    elseif left(parent_id, 7) = "/skins/" then
        template_id = -1
        is_published = false
        dim skinData
        skinData = getSysTemplet(parent_id)
        template_name = skinData(0)
        template_desc = skinData(1)
        template_code = skinData(2)
        template_code2 = skinData(3)
        parent_id = -1
    else
        template_id = -1
        is_published = False
        sql = sql & clng(parent_id)
        rs.open sql, conn, 1, 1
        if not rs.eof then
            template_name = "From " & rs("template_name")
            template_desc = rs("template_desc")
            template_code = rs("template_code")
            template_code2 = rs("template_code2")
        end if
        rs.close()
    end if
    
    
    
%>
<HTML><HEAD><TITLE><%=blogObj.blogTitle%>—控制面板—编辑模板</TITLE>
<link rel="stylesheet" href="<%=cssFile%>" type="text/css" />
<style type="text/css">
td{
    font-size:10pt;
}
</style>
<script language=javascript>
    function saveTemplet(){
        theform = document.getElementById("form1");
        if (theform.template_name.value=="") {
            alert("请输入模板名");
            return;
        }
        if (theform.template_code.value=="") {
            alert("请输入模板代码");
            return;
        }
        theform.actionType.value="save_templet";
        theform.submit();
    }
    
    function saveApply(){
        theform = document.getElementById("form1");
        if (theform.template_name.value=="") {
            alert("请输入模板名");
            return;
        }
        if (theform.template_code.value=="") {
            alert("请输入模板代码");
            return;
        }
        theform.actionType.value="save_apply";
        theform.submit();
    }
    
    function previewTemplet(){

        theform = document.getElementById("form1");
        theform.actionType.value="preview_templet";
        
        tmp=theform.target;
        theform.target = "preview";
        theform.submit();
        theform.target = tmp;
    }
    
    function exit(){
        theform = document.getElementById("form1");
        theform.actionType.value="";
        theform.submit();
    }
</script>
</head>
<body bgcolor="#c1c1c1" leftmargin="0" topmargin="0" style="font-size:10pt">
<div style="width:760px;height:100%;">

<div style="float:left;width: 160px; padding-top:20px">
<!--#include file="menu.asp" -->
</div>

<div style="background:#ffffff; width:580px; height:100%;float:left;padding:20px 10px 10px 10px">
<form name=form1  id=form1 action=templet.asp method=post>
<input type=hidden name=blog_id value="<%=blogObj.blogId%>">
<input type=hidden name=template_id value="<%=template_id%>">
<input type=hidden name=parent_id value="<%=parent_id%>">
<input type=hidden name=actionType value="">
<p>模板名称：<input type=text name=template_name size=60 value="<%=template_name%>"></p>
<p>描述：<br><textarea name=template_desc cols=68 rows=3 ><%=template_desc%></textarea></p>
<p>首页模板代码：<a href="../doc/help.htm#template_define" target="help">模版帮助</a>
<br><textarea name=template_code cols=68 rows=20 wrap="off" ><%=template_code%></textarea></p>
<!--<p>模板是否公开：
    <select name=is_published>
        <option value="false">不公开</option>
        <option value="true" <% if is_published=true then response.write("selected") end if %> >公开</option>
    </select>    
</p>-->


<p>
  正文模板代码：<br>
    <textarea name=template_code2 cols=68 rows=20 wrap="off" id="template_code2" ><%=template_code2%></textarea>
</p>
<p align=center>
<input type=button name="preview" value=" 预览 " onclick="previewTemplet()">
<input type=button name="save_templet" value=" 保存 " onclick="saveTemplet()">
<input type=button name="save_apply" value=" 保存并应用 " onclick="saveApply()">
<input type=button name="cancel" value=" 取消 " onclick="exit()">
</p>    
</form>
</div>
</body>    
</html>    
<!--#include file="../inc/end.asp" -->
